<template>
  <router-layout>
    <div class="union-home">
      <div class="swipe-box">
        <van-swipe :autoplay="3000">
          <van-swipe-item v-for="(image, index) in images" :key="index">
            <div class="img-box">
              <img style="width:100%" :src="image.banner_path">
            </div>
          </van-swipe-item>
        </van-swipe>
      </div>
      <div class="list-box">
        <div class="list van-hairline--bottom" v-for="(item, index) in dataList" :key="index" @click="openLink(item)" >
          <div class="content-box">
            <div class="img-box">
              <img :src="item.file_path" width="100%" alt>
            </div>
            <div class="text-box">
              <p>{{ item.organization_name }}</p>
              <div class="other-text">
                <p>负责人: {{ item.director }}</p>
                <p class="phone">电&nbsp;&nbsp;&nbsp;&nbsp;话: {{ item.telephone }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </router-layout>
</template>

<script>
import { organization_list, organization_listAll } from "@/api/organization";

export default {
  name: "component_name",
  data() {
    return {
      images: [],
      dataList: [],
      listQuery: {
        current: 1,
        limit: 5,
        company_id: localStorage.getItem("companyId")
      }
    };
  },
  methods: {
    openLink(item) {
      this.$router.push({
        path: "/DetailList",
        query: {
          id: item.id
        }
      });
    },
    async initList() {
      let res = await organization_list(this.listQuery);
      if (res.data.status == 100) {
        this.dataList = res.data.data.rows;
      }
    },
    async bannerList() {
      let res = await organization_listAll(this.listQuery);
      if (res.data.status == 100) {
        this.images = res.data.data.rows;
      }
    }
  },
  created() {
    this.bannerList();
    this.initList();
  }
};
</script>
<style lang="scss" scoped>
.union-home {
  .swipe-box {
    .img-box {
      width: 100%;
      overflow: hidden;
    }
  }
  .list {
    .content-box {
      padding: 15px;
      display: flex;
      // align-items: center;
    }
    .img-box {
      width: 133px;
      border-radius: 4px;
      overflow: hidden;
      margin-right: 10px;
    }
    .text-box {
      font-size: 16px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
    .other-text {
      padding-top: 6px;
      font-size: 12px;
      color: #bbb;
    }
  }
}
</style>
